package ihm.model;

import java.util.List;

import service.BalanceService;

import domain.Balance;

public class BalanceModel {
	private List<Balance> balances;

	public BalanceModel() {
		this.balances = BalanceService.getInstance().getAll();
	}

	public List<Balance> getBalances() {
		return balances;
	}

	public void addBalance(Balance balance) {
		balances.add(balance);
	}

	public Balance getBalance(Integer id) {
		for (Balance balance : balances) {
			if (balance.equals(id)) {
				return balance;
			}
		}
		return null;
	}

	public void removeBalance(Integer id) {
		for (Balance balance : balances) {
			if (balance.getId().equals(id)) {
				balances.remove(balance);
			}
		}
	}

	public void reset() {
		this.balances = BalanceService.getInstance().getAll();
	}
}
